﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Sanchay
{
    public partial class Registers : Form
    {
        public Registers()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

            PurchaseHistory PurchaseHistory;
             //Showing "Tractor Purchase Form" using "showForm" method in the Lower panel of SplitContainer
            if (!General.isOpened("PurchaseHistory"))
            {
                PurchaseHistory = new PurchaseHistory();
                PurchaseHistory.Dock = DockStyle.Fill;

                // lblStock.Font = new Font(lblStock.Font, FontStyle.Bold);
            }
            else
            {
                PurchaseHistory = (PurchaseHistory)Application.OpenForms["PurchaseHistory"];
                
            }
                ShowFormInSplitContainer(PurchaseHistory);
        }

        /// <Method>
        /// Method for showing Forms in Split Container's Lower Panel.
        /// </Method>

        public void ShowFormInSplitContainer(Form sender)
        {
            sender.ControlBox = false;
            sender.FormBorderStyle = FormBorderStyle.None;
            sender.ShowInTaskbar = false;
            sender.TopLevel = false;
            sender.Visible = true;

            splitContainer1.Panel2.Controls.Clear();
            splitContainer1.Panel2.Controls.Add(sender);
        }

        private void pictureBox6_Click(object sender, EventArgs e)
        {
            Stock Stock; ;
            /// Showing "Tractor Purchase Form" using "showForm" method in the Lower panel of SplitContainer
            if (!General.isOpened("Stock"))
            {
                Stock = new Stock();
                Stock.Dock = DockStyle.Fill;
               
                lblStock.Font = new Font(lblStock.Font, FontStyle.Bold);
            }
            else
            {
                Stock = (Stock)Application.OpenForms["Stock"];
            }
                ShowFormInSplitContainer(Stock);
        }

    }
}
